package com.kantboot.project.auth.user.controller;

import com.kantboot.project.auth.user.service.ICesAuthUserByWechatService;
import com.kantboot.project.security.vo.LoginVO;
import com.kantboot.project.util.common.util.RestResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 关于微信授权的控制器
 */
@RestController
@RequestMapping("/ces_auth_user_by_wechat")
public class CesAuthUserByWechatController {

    @Resource
    ICesAuthUserByWechatService service;

    /**
     * 微信小程序登录
     * @param code
     * @param encryptedData
     * @param iv
     * @return
     */
    @RequestMapping("/login_by_applet")
    public RestResult<LoginVO> loginByApplet(
            @RequestParam("code") String code,
            @RequestParam("encryptedData") String encryptedData,
            @RequestParam("iv") String iv){
        return RestResult.success(service.loginByApplet(code, encryptedData, iv),"登录成功");
    }

}
